package com.app.common.dataDictionary.PO;

import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;

import com.app.common.dataDictionary.DE.DE_WEALTHAREA_ID;
import com.app.common.dataDictionary.DE.DE_WEALTHAREA_OPPTIME;
import com.app.common.dataDictionary.DE.DE_WEALTHAREA_SFNEW;
import com.app.common.dataDictionary.DE.DE_WEALTHAREA_SORTNUM;
import com.app.common.dataDictionary.DE.DE_WEALTHAREA_TITLE;
import com.css.sword.kernel.base.annotation.PersistObject;
import com.css.sword.kernel.base.dataElement.AbsPersistObject;
import com.css.sword.kernel.base.dataElement.BaseDataElement;
import com.css.sword.kernel.base.dataElement.DateDE;
import com.css.sword.kernel.base.exception.SwordBaseCheckedException;


/**
 * 财富奖区表; InnoDB free: 10240 kB
 */
@PersistObject
public class TWealthareaPO extends AbsPersistObject {
	//private static final long serialVersionUID = -6712568067857031650L;
	private static final long serialVersionUID = 1L;
	private static final BitSet HAS_DEFAULT_VALUE = new BitSet(5);
	
	static{
		HAS_DEFAULT_VALUE.set(4, true);
	}
	
	/**
	 * 物理表名
	 */
	public static final String TABLE_NAME = "t_wealtharea";

	/**
	 * 财富奖区id
	 */
	private DE_WEALTHAREA_ID wealthareaId = DE_WEALTHAREA_ID.getTemplateInstance();

	/**
	 * 财富奖区title
	 */
	private DE_WEALTHAREA_TITLE wealthareaTitle = DE_WEALTHAREA_TITLE.getTemplateInstance();

	/**
	 * 财富奖区最后一次操作时间
	 */
	private DE_WEALTHAREA_OPPTIME wealthareaOpptime = DE_WEALTHAREA_OPPTIME.getTemplateInstance();

	/**
	 * 财富奖区是否new
	 */
	private DE_WEALTHAREA_SFNEW wealthareaSfnew = DE_WEALTHAREA_SFNEW.getTemplateInstance();

	/**
	 * 首页财富奖区排序号
	 */
	private DE_WEALTHAREA_SORTNUM wealthareaSortnum = DE_WEALTHAREA_SORTNUM.getTemplateInstance();


	public TWealthareaPO(){
		this.insertState = new BitSet(5);
		this.updateState = new BitSet(5);
	}

	
	/**
	 * 获取 "财富奖区id" 值
	 */	
	public DE_WEALTHAREA_ID getWealthareaId(){
		return  wealthareaId;
	}
	
	/**
	 * 设置 "财富奖区id" 值
	 */
	public void setWealthareaId(DE_WEALTHAREA_ID wealthareaId) {
		if(wealthareaId == null){
			wealthareaId= DE_WEALTHAREA_ID.getTemplateInstance();
		}
		recordChangeFlag(0);
		this.wealthareaId = wealthareaId;
	}
	
	/**
	 * 获取 "财富奖区title" 值
	 */	
	public DE_WEALTHAREA_TITLE getWealthareaTitle(){
		return  wealthareaTitle;
	}
	
	/**
	 * 设置 "财富奖区title" 值
	 */
	public void setWealthareaTitle(DE_WEALTHAREA_TITLE wealthareaTitle) {
		if(wealthareaTitle == null){
			wealthareaTitle= DE_WEALTHAREA_TITLE.getTemplateInstance();
		}
		recordChangeFlag(1);
		this.wealthareaTitle = wealthareaTitle;
	}
	
	/**
	 * 获取 "财富奖区最后一次操作时间" 值
	 */	
	public DE_WEALTHAREA_OPPTIME getWealthareaOpptime(){
		return  wealthareaOpptime;
	}
	
	/**
	 * 设置 "财富奖区最后一次操作时间" 值
	 */
	public void setWealthareaOpptime(DE_WEALTHAREA_OPPTIME wealthareaOpptime) {
		if(wealthareaOpptime == null){
			wealthareaOpptime= DE_WEALTHAREA_OPPTIME.getTemplateInstance();
		}
		recordChangeFlag(2);
		this.wealthareaOpptime = wealthareaOpptime;
	}
	
	/**
	 * 获取 "财富奖区是否new" 值
	 */	
	public DE_WEALTHAREA_SFNEW getWealthareaSfnew(){
		return  wealthareaSfnew;
	}
	
	/**
	 * 设置 "财富奖区是否new" 值
	 */
	public void setWealthareaSfnew(DE_WEALTHAREA_SFNEW wealthareaSfnew) {
		if(wealthareaSfnew == null){
			wealthareaSfnew= DE_WEALTHAREA_SFNEW.getTemplateInstance();
		}
		recordChangeFlag(3);
		this.wealthareaSfnew = wealthareaSfnew;
	}
	
	/**
	 * 获取 "首页财富奖区排序号" 值
	 */	
	public DE_WEALTHAREA_SORTNUM getWealthareaSortnum(){
		return  wealthareaSortnum;
	}
	
	/**
	 * 设置 "首页财富奖区排序号" 值
	 */
	public void setWealthareaSortnum(DE_WEALTHAREA_SORTNUM wealthareaSortnum) {
		if(wealthareaSortnum == null){
			wealthareaSortnum= DE_WEALTHAREA_SORTNUM.getTemplateInstance();
		}
		recordChangeFlag(4);
		this.wealthareaSortnum = wealthareaSortnum;
	}


	@Override
	public BaseDataElement<?>[] fields(){
		return new BaseDataElement<?>[] {wealthareaId,wealthareaTitle,wealthareaOpptime,wealthareaSfnew,wealthareaSortnum};
	}
	
	@Override
	public String[] fieldNames() {
		return new String[]{"wealthareaId","wealthareaTitle","wealthareaOpptime","wealthareaSfnew","wealthareaSortnum"};
	}
	
	@Override
	public BaseDataElement<?> getFieldValue(String fieldName)  {
		if ("wealthareaId".equals(fieldName)) {
			return wealthareaId;
		}
		if ("wealthareaTitle".equals(fieldName)) {
			return wealthareaTitle;
		}
		if ("wealthareaOpptime".equals(fieldName)) {
			return wealthareaOpptime;
		}
		if ("wealthareaSfnew".equals(fieldName)) {
			return wealthareaSfnew;
		}
		if ("wealthareaSortnum".equals(fieldName)) {
			return wealthareaSortnum;
		}
 
		throw new IllegalArgumentException("PO对象中没有"+fieldName+"字段");
	}
	
	@Override
	public TWealthareaPO setFieldValue(String fieldName, Object fieldValue) throws SwordBaseCheckedException {
		if (fieldValue != null && !(fieldValue instanceof BaseDataElement<?>)) {
			throw new SwordBaseCheckedException("字段值类型不是DataElelement子类型");
		}

		if ("wealthareaId".equals(fieldName)) {
			if (fieldValue == null) {
				setWealthareaId(null);
			} else {
				setWealthareaId((DE_WEALTHAREA_ID) fieldValue);
			}
			return this;
		}

		if ("wealthareaTitle".equals(fieldName)) {
			if (fieldValue == null) {
				setWealthareaTitle(null);
			} else {
				setWealthareaTitle((DE_WEALTHAREA_TITLE) fieldValue);
			}
			return this;
		}

		if ("wealthareaOpptime".equals(fieldName)) {
			if (fieldValue == null) {
				setWealthareaOpptime(null);
			} else {
				setWealthareaOpptime((DE_WEALTHAREA_OPPTIME) fieldValue);
			}
			return this;
		}

		if ("wealthareaSfnew".equals(fieldName)) {
			if (fieldValue == null) {
				setWealthareaSfnew(null);
			} else {
				setWealthareaSfnew((DE_WEALTHAREA_SFNEW) fieldValue);
			}
			return this;
		}

		if ("wealthareaSortnum".equals(fieldName)) {
			if (fieldValue == null) {
				setWealthareaSortnum(null);
			} else {
				setWealthareaSortnum((DE_WEALTHAREA_SORTNUM) fieldValue);
			}
			return this;
		}

		throw new SwordBaseCheckedException("PO对象中没有"+fieldName+"字段");
	}

	@Override
	protected TWealthareaPO clone() {
		TWealthareaPO t = new TWealthareaPO();
		
		t.setWealthareaId(this.wealthareaId);
		t.setWealthareaTitle(this.wealthareaTitle);
		t.setWealthareaOpptime(this.wealthareaOpptime);
		t.setWealthareaSfnew(this.wealthareaSfnew);
		t.setWealthareaSortnum(this.wealthareaSortnum);

		return t;
	}

	@Override
	public TWealthareaPO loadMap(Map<String, Object> dataMap) throws SwordBaseCheckedException {
		Object value = null;

		if(dataMap.containsKey("wealthareaId")){
			value = dataMap.get("wealthareaId");
			
			if (value == null) {
				this.setWealthareaId(null);
			} else {
				if (value instanceof DE_WEALTHAREA_ID) {
					this.setWealthareaId((DE_WEALTHAREA_ID) value);
				}
			    else {
					this.setWealthareaId(new DE_WEALTHAREA_ID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("wealthareaTitle")){
			value = dataMap.get("wealthareaTitle");
			
			if (value == null) {
				this.setWealthareaTitle(null);
			} else {
				if (value instanceof DE_WEALTHAREA_TITLE) {
					this.setWealthareaTitle((DE_WEALTHAREA_TITLE) value);
				}
			    else {
					this.setWealthareaTitle(new DE_WEALTHAREA_TITLE(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("wealthareaOpptime")){
			value = dataMap.get("wealthareaOpptime");
			
			if (value == null) {
				this.setWealthareaOpptime(null);
			} else {
				if (value instanceof DE_WEALTHAREA_OPPTIME) {
					this.setWealthareaOpptime((DE_WEALTHAREA_OPPTIME) value);
				}
				else if(value instanceof java.util.Date){
					this.setWealthareaOpptime(new DE_WEALTHAREA_OPPTIME((java.util.Date)value));
				}
			    else {
					this.setWealthareaOpptime(new DE_WEALTHAREA_OPPTIME(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("wealthareaSfnew")){
			value = dataMap.get("wealthareaSfnew");
			
			if (value == null) {
				this.setWealthareaSfnew(null);
			} else {
				if (value instanceof DE_WEALTHAREA_SFNEW) {
					this.setWealthareaSfnew((DE_WEALTHAREA_SFNEW) value);
				}
			    else {
					this.setWealthareaSfnew(new DE_WEALTHAREA_SFNEW(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("wealthareaSortnum")){
			value = dataMap.get("wealthareaSortnum");
			
			if (value == null) {
				this.setWealthareaSortnum(null);
			} else {
				if (value instanceof DE_WEALTHAREA_SORTNUM) {
					this.setWealthareaSortnum((DE_WEALTHAREA_SORTNUM) value);
				}
			    else {
					this.setWealthareaSortnum(new DE_WEALTHAREA_SORTNUM(value.toString()));
				}
			}
		}

		return this;
	}
	
	@Override
	public Map<String,Object> toMap() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("wealthareaId", wealthareaId);
		dataMap.put("wealthareaTitle", wealthareaTitle);
		dataMap.put("wealthareaOpptime", wealthareaOpptime);
		dataMap.put("wealthareaSfnew", wealthareaSfnew);
		dataMap.put("wealthareaSortnum", wealthareaSortnum);
		
		return dataMap;
	}
	
	@Override
	public Map<String,Object> toMapWithDEValue() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("wealthareaId", (wealthareaId==null?null:wealthareaId.value));
		dataMap.put("wealthareaTitle", (wealthareaTitle==null?null:wealthareaTitle.value));
		dataMap.put("wealthareaOpptime", (wealthareaOpptime==null?null:wealthareaOpptime.value));
		dataMap.put("wealthareaSfnew", (wealthareaSfnew==null?null:wealthareaSfnew.value));
		dataMap.put("wealthareaSortnum", (wealthareaSortnum==null?null:wealthareaSortnum.value));
		
		return dataMap;
	}
	
	@Override
	public TWealthareaPO newInstance() {
		return new TWealthareaPO();
	}
	
	@Override
	public String getTableName(){
		return TABLE_NAME;
	}
	
	@Override
	public BaseDataElement<?>[] getPrimaryKey() {
		return new BaseDataElement<?>[]{wealthareaId};
	}

	@Override
	public void checkNotNull(byte sqlType) throws SwordBaseCheckedException {
		StringBuilder errorMsg = new StringBuilder();
		// insert
		if (sqlType == 0) {
				//只校验不可为空但又没有默认值的字段
				if (wealthareaId.value == null && !HAS_DEFAULT_VALUE.get(0)) {
					errorMsg.append("字段wealthareaId不允许为空\n");
				}

		}
		// update
		else if (sqlType == 1) {
		if (updateState.get(0) && wealthareaId.value == null) {
			errorMsg.append("字段wealthareaId不允许为空\n");
		}

		}
		
		if (errorMsg.length() > 0) {
			errorMsg.setLength(errorMsg.length() - 1);
			throw new SwordBaseCheckedException(errorMsg.toString());
		}
	}

	@Override
	public void updateLrrq(DateDE lrrq) {
	}

	@Override
	public void updateXgrq(DateDE xgrq) {
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();
		str.append("wealthareaId:").append(wealthareaId.value!=null?wealthareaId:"").append(" ").append("wealthareaTitle:").append(wealthareaTitle.value!=null?wealthareaTitle:"").append(" ").append("wealthareaOpptime:").append(wealthareaOpptime.value!=null?wealthareaOpptime:"").append(" ").append("wealthareaSfnew:").append(wealthareaSfnew.value!=null?wealthareaSfnew:"").append(" ").append("wealthareaSortnum:").append(wealthareaSortnum.value!=null?wealthareaSortnum:"").append(" ");
		return str.toString();
	}
	
}
